package com.ysd.dao.impl;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

import com.ysd.entity.Product;
import com.ysd.util.DBManager;

public class ProduDaolmpl {
	public List<Product> getProduList(int pId){
		List<Product> list = new ArrayList<Product>();
		Connection conn = DBManager.getConnection();
		Statement st = null;
		ResultSet rs = null;
		try {
			st = conn.createStatement();
			rs = st.executeQuery("select * from product where productId="+pId);
			
			while(rs.next()) {
				int productId = rs.getInt("productId");
				String productName = rs.getString("productName");
				String productPrice = rs.getString("productPrice");
				String markPrice = rs.getString("markPrice");
				String imgs = rs.getString("imgs");
				String riqi = rs.getString("riqi");
				String exp = rs.getString("exp");
				String changJia = rs.getString("changJia");
				int categoryId = rs.getInt("categoryId");
				Product product = new Product(productId, productName, productPrice, markPrice, imgs, riqi, exp, changJia, categoryId);
				list.add(product);
			}
			return list;
		
		} catch (SQLException e) {
			e.printStackTrace();
			return null;
		}finally {
			DBManager.closeAll(conn, st, rs);
		}
	}
}
